
#include <vector>
#include <iostream>

using namespace std;

class A
{
public:
    int idx;

    A(int x): idx(x)
    {
        cout << "construct " << x << endl;
    }

	A(const A&& other)
	{
        idx = other.idx;
        cout << "move " << idx << endl;
	}

	A(const A& other)
	{
        idx = other.idx;
        cout << "copy " << idx << endl;
	}

    ~A()
    {
        cout << "destruct " << idx << endl;
    }

};

int main()
{
    vector<A> va;
    cout << "begin" << endl;

    {
        A a(1);
        va.push_back(a);
        cout << "break1" << endl;
        va.pop_back();
    }

    {
        va.push_back(A(2));
        cout << "break2" << endl;
        va.pop_back();
    }

    {
        va.emplace_back(3);
        cout << "break3" << endl;
        va.pop_back();
    }

    {
        A a(4);
        va.emplace_back(a);
        cout << "break4" << endl;
        va.pop_back();
    }

    {
        A a(5);
        va.emplace_back(std::move(a));
        cout << "break5" << endl;
        va.pop_back();
    }

    cout << "end" << endl;

}
